//
//  BaseTableViewController.swift
//  SinaWeiBo
//
//  Created by tuyue on 16/3/6.
//  Copyright © 2016年 xueyang.co.ltd. All rights reserved.
//

import UIKit


class BaseTableViewController: UITableViewController ,VisitorLoginViewDelegate{
    
    var userLogin = UserAccount.sharedAccount.userLogin
    var visitorLoginView: VisitorLoginView?
    
    override func loadView() {
        
        if userLogin {
            
            super.loadView()
            //            print("hello")
        }else {
            visitorLoginView = VisitorLoginView()
            visitorLoginView?.delegate = self
            view = visitorLoginView
            setupNavBar()
            
        }
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        
    }
    
    func visitorLoginViewDidRegister(){
        print("注册")
    }
    
    func  visitorLoginViewDidLogin(){
        print("登陆")
    }
    
    func  visitorLoginViewDidgoLook(){
        print("去关注")
    }
    
    
    func setupNavBar(){
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "登录", style: .Plain, target: self, action: "userWillLogin")
        
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "注册", style: .Plain, target: self, action: "userWillRegisterIn")
        
    }
    
    
    func userWillLogin(){
        let oAuth = oAuthViewController()
        let nav = UINavigationController(rootViewController: oAuth )
        presentViewController(nav, animated: true, completion: nil)
        
    }
    
    func userWillRegisterIn(){
        visitorLoginViewDidRegister()
    }
    
    
    
}
